var app = new Vue({
    el: "#player",
    data: {
        query: "",//歌曲关键字
        musiclist: [],//歌曲列表数组
        musicUrl: "",//歌曲的url
        imageUrl: "",//歌曲图片的url
        comment: [],//歌曲的图片数组
        isplay: false,//唱片的旋转
    },
    methods: {
        //全部歌曲
        searchMusic: function () {
            this.musiclist = [];
            axios.post("https://autumnfish.cn/search?keywords=" + this.query)
                .then(res => {
                    //console.log(res);//输出查询所有的歌曲信息
                    this.musiclist = res.data.result.songs;
                }, function (err) {
                    console.log("出错了")
                })
        },
        //播放歌曲
        playMusic: function (musicId) {
            this.musicUrl = "",
                this.imageUrl = "";
            this.comment = [];
            axios.get("https://autumnfish.cn/song/url?id=" + musicId)
                .then(res => {
                    //console.log(res);//输出具体歌曲信息
                    this.musicUrl = res.data.data[0].url;
                }, function (err) {
                    console.log("出错了")
                })
            //歌曲图片
            axios.get("https://autumnfish.cn/song/detail?ids=" + musicId)
                .then(res => {
                    this.imageUrl = res.data.songs[0].al.picUrl;//图片位置
                }, function (err) {
                    console.log(err)
                })
            //歌曲评论
            axios.get("https://autumnfish.cn/comment/hot?type=0&id=" + musicId)
                .then(res => {
                    //console.log(res.data.hotComments);输出查询的评论数组
                    this.comment = res.data.hotComments;
                }, function (err) {
                    console.log(err)
                })
        },
        //唱片旋转
        playimage: function () {
            this.isplay = true;
        },
        pauseimage: function () {
            this.isplay = false;
        }
    }
})